<script type="text/javascript">
function cal_total(total){
  var q = 0;
  var mul = 0.0;
  for(var i=0; i<parseInt(total); i++){
    q = q + parseFloat(document.getElementById("q_"+i).value);
    mul = mul + (parseFloat(document.getElementById("q_"+i).value) * parseFloat(document.getElementById("s_"+i).value));
  }
  document.getElementById("total_q").innerHTML = q;
  document.getElementById("total_s").innerHTML = mul;
}
</script>
<select name="exam_schedule[exam_id]" id="exam_schedule_exam_id" onchange="<%=remote_function(:update=>"total_question", :url=>{:action=>:total_question}, :with=>"'exam_id='+$('exam_schedule_exam_id').value")%>">
  <option value="0">--กรุณาเลือก--</option>
  <%@exams.each do |e|%>
    <option value="<%=e.id%>"><%="#{e.name} (#{e.exam_questions.size} ข้อ,ความยากเฉลี่ย:#{number_with_precision(e.average_difficult, :precision=>2)})"%></option>
  <%end%>
</select>